home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / TIMER.H < prev    next >
C/C++ Source or Header  |  1992-08-24  |  2KB  |  61 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. //
  13. // Created: BMK 07/14/89 -- Initial design and implementation
  14. // Updated: LGO 09/23/89 -- Conform to COOL coding style
  15. // Updated: AFM 12/31/89 -- OS/2 port
  16. // Updated: DLS 03/22/91 -- New lite version
  17. // Updated: JAM 08/12/92 -- made standard functions by default, define
  18. //                          UNIXTIMER to use sys/ #includes and features
  19. //
  20. // The Timer class provides timing code  for performance evaluation.  This code
  21. // was originally written by Joe Rahmeh at UT Austin.
  22. //
  23. // FUTURE
  24. // JAM -- Want to also remove <sys/timeb.h> or at least make POSIX
  25. //
  26.  
  27.  
  28. #include <time.h>    // standard (time_t)
  29. #if defined(UNIXTIMER)
  30. #include <sys/timeb.h>  // not standard, but UNIX and MSDOS (timeb,ftime())
  31. #include <sys/types.h>
  32. #include <sys/time.h>   // Shouldn't this be just <time.h>?
  33. #include <sys/resource.h>
  34. #endif   // extra UNIX functions and functionality
  35.  
  36.  
  37. class CoolTimer {
  38. public:
  39.   CoolTimer () {mark();}    // constructor
  40.   
  41.   void mark ();        // mark timer
  42.   
  43.   long user ();        // user        time (ms) since last Mark
  44.   long system ();    // system      time (ms) since last Mark
  45.   long all ();        // user+system time (ms) since last Mark
  46.   long real ();        // real        time (ms) since last Mark
  47.   
  48.   long user_usec ();    // user        time (us) since last Mark
  49.   long system_usec ();    // system      time (us) since last Mark
  50.   long all_usec ();    // user+system time (us) since last Mark
  51.  
  52. private:
  53. #if !defined(UNIXTIMER)    // standard functions
  54.   clock_t usage0;
  55. #else
  56.   rusage  usage0;    // rusage structure at last mark
  57.   timeb   real0;    // elapsed real time at last mark
  58. #endif
  59. };
  60.  
  61.